import { RouteRecordRaw } from "vue-router";
import HomeView from "@/views/EditorExampleView.vue";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import NoAuthView from "@/views/NoAuthView.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import QuestionsView from "@/views/question/QuestionsView.vue";
import QuestionSubmitView from "@/views/question/QuestionSubmitView.vue";
import EditorExampleView from "@/views/EditorExampleView.vue";
import ToDoView from "@/views/ToDoView.vue";

export const routes: Array<RouteRecordRaw> = [
  //  todo oneLevelMenu仅仅是标识功能，与hideInMenu配置使用，与GlobalHeader组件联动
  // todo 用户模块
  {
    path: "/user",
    name: "用户",
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
    ],
    meta: {
      hideInMenu: true,
      oneLevelMenu: false,
    },
  },
  // todo 题目模块（题库：所有公开题的集合；题单：题单）
  {
    path: "/question",
    name: "题目",
    children: [
      {
        path: "/questions",
        name: "浏览题目",
        component: QuestionsView,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
      {
        path: "/question_submit",
        name: "浏览题目提交",
        component: QuestionSubmitView,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
      {
        path: "/view/question/:id",
        name: "在线做题",
        component: ToDoView,
        props: true,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
      {
        path: "/add/question",
        name: "创建题目",
        component: AddQuestionView,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
      {
        path: "/update/question",
        name: "更新题目",
        component: AddQuestionView,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
      {
        path: "/manage/question/",
        name: "管理题目",
        component: ToDoView,
        meta: {
          hideInMenu: true,
          // access: ACCESS_ENUM.ADMIN,
        },
      },
    ],
    meta: {
      hideInMenu: false,
      OneLevelMenu: false,
    },
  },
  // todo 反馈模块
  {
    path: "/feedback",
    name: "反馈",
    children: [
      {
        path: "/feedback/myfb",
        name: "我的反馈",
        component: ToDoView,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
      {
        path: "/feedback/res",
        name: "反馈结果",
        component: ToDoView,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
      {
        path: "/feedback/handle",
        name: "反馈处理",
        component: ToDoView,
        // todo 可视情况控制子菜单是否显示
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: true,
        },
      },
    ],
    meta: {
      hideInMenu: false,
      oneLevelMenu: false,
    },
  },
  // todo 系统模块
  {
    path: "/system",
    name: "系统",
    children: [
      {
        path: "/system/monitor",
        name: "系统监控",
        component: ToDoView,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
      {
        path: "/system/config",
        name: "参数配置",
        component: ToDoView,
        meta: {
          // access: ACCESS_ENUM.USER,
          hideInMenu: false,
        },
      },
    ],
    meta: {
      hideInMenu: false,
      oneLevelMenu: false,
    },
  },
  // todo 首页
  {
    path: "/",
    name: "首页",
    component: EditorExampleView,
    meta: {
      hideInMenu: true,
      OneLevelMenu: true,
    },
  },
  // todo 无权限页
  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuthView,
    meta: {
      hideInMenu: true,
      oneLevelMenu: true,
    },
  },
];
